$(function (){
    let app = new Vue({
        el: "#app",
        data: {
            sysTitle: "固定资源管理系统",
            userID: "10011001111",
            userName: "林耿奎",
            userImageSrc: "images/common/headPhoto.png",
            backImageSrc: "images/common/back.jpg",
            subList1: [
                {href:"properties.html", li: " 资源管理"},
                {href:"departments.html", li: " 部门管理"},
                {href:"employees.html", li: " 员工管理"}
            ],
            subList2: [
                {href:"infos.html", li: " 个人信息"},
                {href:"passwords.html", li: " 密码修改"},
                {href:"util/login.html", li: " 注销"}
            ],
            departments: [{name: "资源部1", value: "1"},{name: "资源部2", value: "2"},{name: "资源部3", value: "3"},{name: "资源部4", value: "4"}],
            selectDepartment: "",
            selectManger: "",
            dataList: [],//当前页要展示的列表数据
            dialogFormVisible: false,//添加表单是否可见
            dialogFormVisible4Edit:false,//编辑表单是否可见
            formData: {},//表单数据
            rules: {//校验规则
                id: [{ required: true, message: '部门编号为必填项', trigger: 'blur' }],
                name: [{ required: true, message: '部门名称为必填项', trigger: 'blur' }],
                info: [{ required: true, message: '部门简介为必填项', trigger: 'blur' }],
                time: [{ required: true, message: '部门注册时间为必填项', trigger: 'blur' }],
            },
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize:8,//每页显示的记录数
                total:0,//总记录数
                id: "",
                eName: "",

            }
        },
        created(){
            this.getIDAndName();
        },
        methods: {
            getIDAndName(){
                if(sessionStorage.getItem("userID") === null)
                {
                    location.href = "util/login.html";
                }else {
                    this.userID = sessionStorage.getItem("userID").toString();
                    this.userName = sessionStorage.getItem("userName").toString();
                    this.userImageSrc = "../" + sessionStorage.getItem("userImageSrc").toString()
                }
            },
            //分页查询
            getAll() {
               /* //组织参数，拼接url请求地址
                // console.log(this.pagination.type);
                param = "?tell="+this.pagination.tell;
                param +="&name="+this.pagination.name;
                param +="&time="+this.pagination.time;
                //发送异步请求
                axios.get("http://localhost:16/users/"+this.pagination.currentPage+"/"+this.pagination.pageSize+param).then((res)=>{
                    this.pagination.pageSize = res.data.data.size;
                    this.pagination.currentPage = res.data.data.current;
                    this.pagination.total = res.data.data.total;
                    this.dataList = res.data.data.records;
                });*/
            },

            //切换页码
            handleCurrentChange(currentPage) {
                //修改页码值为当前选中的页码值
                this.pagination.currentPage = currentPage;
                //执行查询
                this.getAll();
            },

            //弹出添加窗口
            handleCreate() {
                this.dialogFormVisible = true;
                this.resetForm();
            },

            //重置表单
            resetForm() {
                this.formData = {};
            },

            //添加
            handleAdd () {
               /* axios.post("http://localhost:16/users", this.formData).then((res)=>{
                    if(res.data.flag){
                        //关闭弹窗
                        this.dialogFormVisible = false;
                        this.$message.success(res.data.msg);
                    }else
                        this.$message.error(res.data.msg);
                }).finally(()=>{
                    //重新加载数据
                    this.getAll();
                });*/
            },

            //取消
            cancel(){
                this.dialogFormVisible = false;
                this.dialogFormVisible4Edit = false;
                this.$message.info("操作已取消");
            },

            // 删除
            handleDelete(row) {
             /*   this.$confirm("是否要删除"+row.name+"用户的信息", "删除提示", {type:"info"}).then(()=>{
                    axios.delete("http://localhost:16/users/"+row.id).then((res)=>{
                        if(res.data.flag){
                            this.$message.success(res.data.msg);
                        }else
                            this.$message.error(res.data.msg);
                    }).finally(()=>{
                        //重新加载数据
                        this.getAll();
                    });
                }).catch(()=>{
                    this.$message.info("取消操作");
                });*/

            },

            //弹出编辑窗口
            handleUpdate(row) {
                /*axios.get("http://localhost:16/users/"+row.id).then((res)=>{
                    if(res.data.flag && res.data.data != null)
                    {*/
                        this.dialogFormVisible4Edit = true;
                 /*       this.formData = res.data.data;
                    }else {
                        this.$message.error("数据同步失败，自动刷新");
                    }
                }).finally(()=>{
                    this.getAll();
                });*/
            },

            //修改
            handleEdit() {
              /*  axios.put("http://localhost:16/users", this.formData).then((res)=>{
                    if(res.data.flag)
                    {
                        this.dialogFormVisible4Edit = false;
                        this.$message.success(res.data.msg);
                    }else {
                        this.$message.error(res.data.msg);
                    }
                }).finally(()=>{
                    this.getAll();
                });*/
            },


        }
    });
    var left_nav = $(".left-nav");
    var left_lis = left_nav.children("li");
    var left_sub_nav = left_lis[0].children[1];
    $(left_sub_nav).children("li").eq(1).children("a").addClass("current");
   /* lis.addClass("current");*/
});